package log

import (
	"fmt"
	"time"
)

var canPrintln = true

// SetPrintln 设置打印开关
func SetPrintln(flag bool) {
	canPrintln = flag
}

// Println 打印消息
func Println(msg ...any) {
	if canPrintln {
		msg = append([]any{time.Now().Format("2006-1-2 15:04:05")}, msg...)
		fmt.Println(msg...)
	}
}

// Printfln 打印消息
func Printfln(format string, msg ...any) {
	if canPrintln {
		format = time.Now().Format("2006-1-2 15:04:05") + " " + format + "\n"
		fmt.Printf(format, msg...)
	}
}
